<a href="arrange.php">返回</a>
<div align="center">
	<h1>添加考试</h1>
	<form method="post" action="">
		<table>
			<tr><th>考试班级：</th><td><input type="text" name="class" /></td></tr>
			<tr><th>考试科目：</th><td><input type="text" name="course" /></td></tr>
			<tr><th>考试时间：</th><td><input  type="text" name="time"/></td></tr>
			<tr><th>考试地点：</th><td><input type="text" name="room"/></td></tr>
			<tr><th>监考老师1：</th><td><input  type="text" name="teacher1"/></td></tr>
			<tr><th>监考老师2：</th><td><input  type="text" name="teacher2"/></td></tr>
			<tr>
				<td colspan="2" class="td-btn">
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="submit" value="保存资料" class="button"/>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="reset" value="重新填写" class="button" />
				</td>
			</tr>
		</table>
	</form>
</div>
<?php
	if(!empty($_POST)){
		$class = $_POST['class'];
		$course = $_POST['course'];
		$time = $_POST['time']; 
		$room = $_POST['room'];
		$tea1 = $_POST['teacher1'];
		$tea2 = $_POST['teacher2'];
		$tea = $tea1."、".$tea2;
		if($class!="" && $course!="" && $time!="" && $room!="" && $tea!=""){
			try{
			$db =new pdo("mysql:host=localhost;dbname=db_database10;charset=utf8","root","");
			}
			catch(Exception $exc){
				echo $exc->getMessage();
			}
			$stmt = $db->prepare('insert into exam(class,course,time,room,teacher) values(?,?,?,?,?)');
			$stmt->execute(array($class,$course,$time,$room,$tea));
			echo "<script>alert('添加成功！');location='arrange.php';</script>";
		}
		else
			echo "<script>alert('内容不能留空！请重新填写');location='add.php';</script>";
	}
?>
